﻿namespace EyeOpen.TimeAssistant.Server.BootStrapper
{
    using EyeOpen.Dependency;
    using EyeOpen.TimeAssistant.Data;
    using EyeOpen.TimeAssistant.Data.Nhibernate;
    using NHibernate;

    public class TimeAssistantDataContextFactory
    {
        public ITimeAssistantDataContext CreateDataContext()
        {
            DependencyContainerService
                .Configure<TimeAssistantContainerConfigurator>();

            var session =
                DependencyContainerService
                    .Instance
                    .Resolve<ISessionFactory>(TimeAssistantContainerConfigurator.TimeAssistantConfigurationName);

            return new NhibernateTimeAssistantDataContext(session.OpenSession());
        }
    }
}